﻿Imports MeoTom.Core.BLL
Imports MeoTom.Core

Namespace Control

    Partial Public Class LinkCategoryEdit
        Inherits System.Web.UI.UserControl
        Public lc As New LinkCat()
        Public util2 As New Utilities.Common()

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                Dim previousPage As String = ""
                If Request.QueryString.ToString = vbNullString Then
                    previousPage = Server.UrlEncode(Request.ServerVariables("PATH_INFO"))
                Else
                    previousPage = Server.UrlEncode(Request.ServerVariables("PATH_INFO") & "?" & Request.QueryString.ToString())
                End If
                util2.ValidateLogin(previousPage)

                LoadLinkCat()
            End If
        End Sub

        Public Sub LoadLinkCat()
            lc.CatID = Integer.Parse(Request.QueryString("ID"))
            lc.GetByID()

            txtTitle.Text = lc.CatName
            txtDesc.Text = lc.Description
        End Sub

        Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
            lc.CatID = Integer.Parse(Request.QueryString("ID"))
            lc.CatName = util2.NoHTML(txtTitle.Text)
            lc.Description = util2.NoHTML(txtDesc.Text)
            lc.Update()
            lc.WriteLinkCat(5)
            Response.Redirect("/mt-inside/LinkCategory.aspx", False)
        End Sub
    End Class
End Namespace